﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import Display.DialogUI.*;
    import Transactions.*;
    import Classes.util.*;
    import Display.*;
    import L10n.*;

    public class CrossPromoManager {

        protected var m_xpromo:Boolean;
        protected var m_source:String;
        protected var m_affiliate:String;
        protected var m_creative:String;
        protected var m_quest:String;

        public function CrossPromoManager(_arg1:Object){
            var _local2:String = String(_arg1.src);
            var _local3:String = String(_arg1.aff);
            var _local4:String = String(_arg1.crt);
            var _local5:XML = this.validateArgs(_local2, _local3, _local4);
            if (_local5 != null){
                this.m_xpromo = true;
                this.m_source = _local2;
                this.m_affiliate = _local3;
                this.m_creative = _local4;
                this.m_quest = _local5.@quest;
            };
        }
        public function get isSessionFromXpromo():Boolean{
            if (LocaleHelper.localSetting.sns.feature_xpromo == false){
                return (false);
            };
            return (this.m_xpromo);
        }
        public function get localizationPrefix():String{
            return ((this.m_xpromo) ? ((((this.m_source + "_") + this.m_affiliate) + "_") + this.m_creative) : null);
        }
        protected function validateArgs(_arg1:String, _arg2:String, _arg3:String):XML{
            var xml:* = null;
            var src:* = _arg1;
            var aff:* = _arg2;
            var crt:* = _arg3;
            xml = Global.gameSettings.getXpromoXMLByName(src);
            if (xml == null){
                return (null);
            };
            var entries:* = xml.entry.(((@aff == aff)) && ((@crt == crt)));
            return (((entries.length())>0) ? entries[0] : null);
        }
        public function handleStartup():void{
            if (!this.isSessionFromXpromo){
                return;
            };
            var _local1 = (this.localizationPrefix + "_intro");
            var _local2:String = ZLoc.t("XPromo", _local1);
            UI.displayPopup(new GenericDialog(_local2, "", GenericDialogView.TYPE_OK, null, _local1), true);
            GameTransactionManager.addTransaction(new TStartManualQuest(this.m_quest));
        }
        public function handleEndOfTutorial():void{
            if (!this.isSessionFromXpromo){
                return;
            };
            GameTransactionManager.addTransaction(new TStartManualQuest(this.m_quest));
        }
        public function handleReward(_arg1:String, _arg2:String):void{
            Global.questManager.callEpilogueWithUrl(_arg1, _arg2);
        }

    }
}//package Classes 
